#include "AxisRangeSet.h"
#include "qmessagebox.h"
AxisRangeSet::AxisRangeSet(QDialog *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	connect(ui.btn_apply, &QPushButton::clicked, this, &AxisRangeSet::Apply);
	connect(ui.btn_cancel, &QPushButton::clicked, [=]()
	{
		this->close();
	});
}

AxisRangeSet::~AxisRangeSet()
{
}

void AxisRangeSet::Apply()
{
	double lower = 0, upper = 0;
	lower = ui.dsb_lower->value();
	upper = ui.dsb_upper->value();
	if (lower >= upper)
	{
		QMessageBox::warning(this, "warning", "The lower limit cannot be lower than the upper limit", QMessageBox::Ok);
		return;
	}
	emit updateAxisRange(lower, upper);
	this->close();
}